package com.HeJing.面向对象特征之一_封装;

/**
 * ClassName: Animal
 * Package: com.HeJing.封装
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-03-24 10:47
 * @Version: 1.0
 */
public class Animal {
    // 属性:
    String name;
    private int legs;

    // 方法:

    public void setLegs(int l) {
        if(l >= 0 && l % 2 == 0) {
            legs = l;
        }else {
            System.out.println("动物脚的输入不符合规范");
        }
    }

    public int getLegs() {
        return legs;
    }
    public void eat() {
        System.out.println("动物在吃饭");
    }
}



























